<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="row-fluid">
    <div class="span12">
        <div class="well grey span11">
            <div class="well-header">
                <h5>公司修改</h5>
            </div>

            <div class="well-content no-search">
            <form id="company">
                <input type="hidden" name="id" value="${company.id}" />
                <div class="form_row">
                    <label class="field_name align_right">公司名：</label>
                    <div class="field">
                        <input name="name" class="span4" type="text" value="${company.name}">
                    </div>
                </div>
                
                <div class="form_row">
                    <label class="field_name align_right">地址：</label>
                    <div class="field">
                        <input name="address" class="span2" type="text" value="${company.address}">
                    </div>
                </div>
                
                <div class="form_row">
                    <label class="field_name align_right">邮箱：</label>
                    <div class="field">
                        <input name="email" class="span4" type="text" value="${company.email}">
                    </div>
                </div>
                
                
                <div class="form_row">
                    <div class="field">
                        <a id="updateCompany" href="javascript:void(0)" class="btn red submit">提交</a>
                        <a id="cancel" href="javascript:void(0)" class="btn light_blue cancel">取消</a>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
jQuery(function($){
	$("input[name='birthday']").datetimepicker({
		format:"yyyy-mm-dd",
	    autoclose: true,
	    pickTime: false,
	    minView: '2',
	    todayBtn: true
	});
	
	$("#updateCompany").click(function(){
		Company.validateCompany(function(){
			$.ajax({
				url: "company/update/",
				type: 'post',
				data: $("form").serialize(),
				dataType: "json",
				success: function(json) {
					if (json.code == "0") {
						Fitz.alert("修改成功!", function(){
							Fitz.listPage("company/list");
						});
					} else {
						Fitz.alert(json.message);
					}
				},
				error: function(xhr, textStatus, errorThrown){
					alert(errorThrown);
				}
			});
		});
	});
	
	$("#cancel").click(function(){
		Fitz.listPage("company/list");
	});
})
</script>
